package com.example.myproject.mapper;

import com.example.myproject.model.Marking;
import org.apache.ibatis.annotations.*;

@Mapper
public interface MarkingMapper {
    @Insert("INSERT INTO marking (torrent_id, user_id, weight_factor, score, marking_time) " +
            "VALUES (#{torrent_id}, #{user_id}, #{weight_factor}, #{score}, #{marking_time})")
    @Options(useGeneratedKeys = true, keyProperty = "marrking_id")
    void insert(Marking marking);

    @Select("SELECT AVG(score * weight_factor) FROM marking WHERE torrent_id = #{torrentId}")
    Double calculateAverageScore(@Param("torrentId") Long torrentId);


}